package com.chenglu.android.redpacket;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.mine.bean.CollectBean;
import com.chenglu.android.mine.collect.adapter.CouponListAdapter;
import com.chenglu.android.redpacket.bean.PacketBean;

import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023/7/24 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：
 */
public class PacketAdapter extends BaseQuickAdapter<PacketBean.Data.Records, BaseViewHolder> {

    private Context mContext;

//    private final ViewBinderHelper viewBinderHelper = new ViewBinderHelper();

    public PacketAdapter(Context context, @Nullable List<PacketBean.Data.Records> data) {
        super(R.layout.item_packet, data);
        this.mContext = context;

    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PacketBean.Data.Records item) {

        if (item == null) {
            return;
        }
        ImageView imageView = helper.getView(R.id.iv_head_pic);

        GlideUtils.setImageView(mContext,item.getAvatar(),imageView,8);

        helper.setText(R.id.tv_name,item.getNickName());

        helper.setText(R.id.tv_item_des,item.getTitle());

        helper.setText(R.id.tv_item_time,item.getCreateTime());

        if(item.getStatus()==0){
            helper.setBackgroundRes(R.id.iv_bg_red_packet,R.drawable.red_packet_bg_default);
            helper.setBackgroundRes(R.id.iv_red_packet,R.drawable.red_packet_icon_small_default);
        }else if(item.getStatus()==1) {
            helper.setBackgroundRes(R.id.iv_bg_red_packet,R.drawable.red_packet_bg_press);
            helper.setBackgroundRes(R.id.iv_red_packet,R.drawable.red_packet_icon_small_press);
        }

        if(item.getIsReceive()==0){
            helper.setBackgroundRes(R.id.iv_bg_red_packet,R.drawable.red_packet_bg_press);
            helper.setBackgroundRes(R.id.iv_red_packet,R.drawable.red_packet_icon_small_press);
        }else {
            helper.setBackgroundRes(R.id.iv_bg_red_packet,R.drawable.red_packet_bg_default);
            helper.setBackgroundRes(R.id.iv_red_packet,R.drawable.red_packet_icon_small_default);
        }
        helper.addOnClickListener(R.id.fl_red_packet);


    }

}
